//Stephen Kirksharian
//Robert Harkreader
//CPSC 321
//DUE 4/27/08


//Variable shifting unit
`define LEFT   2'b00
`define RIGHT  2'b01
`define RIGHTA 2'b10

module shift(in,control,shamt,out);
	input [31:0]in;
	input [1:0]control;
	input [4:0]shamt;
	output [31:0]out;
	reg [31:0]out;
	reg [7:0] temp1, temp2;
	reg [31:0]temp;

always @(in or control or shamt) begin
	case(control)
	  `LEFT:   #5 out = in<<shamt;
	  `RIGHT:  #5 out= in>>shamt;
	  `RIGHTA: begin
		#5 temp=out;
		repeat (shamt) begin
			temp=temp>>1;
			temp={{in[31]},temp[30:0]};
		end
		
		out={{in[31]},temp[30:0]};
	   end
	endcase
end 
endmodule

	
